<?php

/**
 * This is the model class for table "hole_score".
 *
 * The followings are the available columns in table 'hole_score':
 * @property integer $ID
 * @property integer $HOLE_GOLF_COURSE_ID
 * @property integer $SCORE
 * @property integer $LIVE_SCORE_ID
 * @property integer $LIVE_SCORE_TOUR_ID
 *
 * The followings are the available model relations:
 * @property HoleGolfCourse $hOLEGOLFCOURSE
 * @property LiveScore $lIVESCORE
 * @property LiveScoreTour $lIVESCORETOUR
 */
class HoleScore extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return HoleScore the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'hole_score';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('HOLE_GOLF_COURSE_ID, SCORE, LIVE_SCORE_ID, LIVE_SCORE_TOUR_ID', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID, HOLE_GOLF_COURSE_ID, SCORE, LIVE_SCORE_ID, LIVE_SCORE_TOUR_ID', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'hOLEGOLFCOURSE' => array(self::BELONGS_TO, 'HoleGolfCourse', 'HOLE_GOLF_COURSE_ID'),
			'lIVESCORE' => array(self::BELONGS_TO, 'LiveScore', 'LIVE_SCORE_ID'),
			'lIVESCORETOUR' => array(self::BELONGS_TO, 'LiveScoreTour', 'LIVE_SCORE_TOUR_ID'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID' => 'ID',
			'HOLE_GOLF_COURSE_ID' => 'Hole Golf Course',
			'SCORE' => 'Score',
			'LIVE_SCORE_ID' => 'Live Score',
			'LIVE_SCORE_TOUR_ID' => 'Live Score Tour',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID',$this->ID);
		$criteria->compare('HOLE_GOLF_COURSE_ID',$this->HOLE_GOLF_COURSE_ID);
		$criteria->compare('SCORE',$this->SCORE);
		$criteria->compare('LIVE_SCORE_ID',$this->LIVE_SCORE_ID);
		$criteria->compare('LIVE_SCORE_TOUR_ID',$this->LIVE_SCORE_TOUR_ID);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}